﻿using System;
using Common.Unity.Extensions.PropertyMapper.Policies;
using Microsoft.Practices.ObjectBuilder2;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;
using Microsoft.Practices.Unity.ObjectBuilder;
using Common.Unity.Extensions;

namespace Common.Unity.Extensions.PropertyMapper
{
	class PropertyMapperExtension : UnityContainerExtension
	{
		protected override void Initialize()
		{
			Context.Strategies.AddNew<PropertyMappingContextStrategy>( UnityBuildStage.Creation );
			Context.Strategies.AddNew<ReflectionPropertyMappingStrategy>( UnityBuildStage.Creation );
			Context.Strategies.AddNew<PropertyMappingStrategy<PropertyMappingExpressionsPolicy>>( UnityBuildStage.Creation );
			Context.Strategies.AddNew<PropertyMappingStrategy<SimilarPropertiesPolicy>>( UnityBuildStage.Creation );

			// Ensure properties are being set:
			Context.Strategies.AddNewOnce<PropertySetterStrategy>( UnityBuildStage.Initialization );
		}
	}
}